package shuati.meituan;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @author : LdLtd
 * @Date : 2024/4/6
 * @Description:
 * 给出n个字符串，每行选一个字符，不能重复
 * 计算有多少方案
 */
public class c040604 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String [] str=new String[n];
        sc.nextLine();
        for (int i = 0; i < n; i++) {
            str[i]=sc.nextLine();
        }
        long res= (long) (countOptions(str)%mod);
        System.out.println(res);
    }
    public static Set<Character> set=new HashSet<>();
    public static double mod=1e9+7;
    public  static  String[] strings;
    public static boolean [] visited;
    public static long countOptions(String[] ss) {
        strings=ss;
        int rows = strings.length;
        visited = new boolean[26]; // 记录每个字符是否被访问过
        return (long) (backtrack(0)%mod);
    }
    public static long backtrack( int row) {
        if (row == strings.length) {
            return 1; // 已经处理完所有行，找到了一种方案
        }
        long count = 0;
        String s = strings[row];
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            int index = ch - 'a'; // 字符在数组中的索引
            if (!visited[index]) {
                visited[index] = true;
                long backtrack = (long) (backtrack( row + 1)%mod);// 递归到下一行时，从第一个字符开始选择
                count= (long) ((count+backtrack)%mod);
                visited[index] = false;
            }
        }
        return (long) (count%mod);
    }
}
